<?php

namespace app\common\model;

use think\Model;


class Contact extends Model
{





    // 表名
    protected $name = 'contact_us';

    // 自动写入时间戳字段
    protected $autoWriteTimestamp = false;

    // 定义时间戳字段名
    protected $createTime = false;
    protected $updateTime = false;
    protected $deleteTime = false;

    // 追加属性
    protected $append = [
        'public_account_image_array',
        'enterprise_wechat_image_array',
    ];
 
    public function getPublicAccountImageArrayAttr($value, $data)
    {
        if (isset($data['public_account_image']) && $data['public_account_image']) {
            $images = explode(',', $data['public_account_image']);
            foreach ($images as &$v) {
                $v = cdnurl($v, true);
            }
            return $images;
        }
        return [];
    }
    
    public function getEnterpriseWechatImageArrayAttr($value, $data)
    {
        if (isset($data['enterprise_wechat_image']) && $data['enterprise_wechat_image']) {
            $images = explode(',', $data['enterprise_wechat_image']);
            foreach ($images as &$v) {
                $v = cdnurl($v, true);
            }
            return $images;
        }
        return [];
    }
}
